#!/usr/bin/env node
const os = require('os');
const exec = require('child_process').exec;

console.log('architecture', process.arch);
console.log('platform', process.platform);
console.log('操作系统发布版本:', os.release());
console.log('');

console.log('process id:', process.pid);
console.log('exePath', process.execPath);
console.log('');

console.log('Press any key to continue...');
process.stdin.once('data', () => {
    console.log('Continuing execution...');
});

exec('ps aux', (error, stdout, stderr) => {
    if (error) {
        console.error(`exec error: ${error}`);
        return;
    }
    console.log('ps aux output:', stdout);
});

console.log('node version', process.version);
console.log('user id', os.userInfo().uid);
console.log('group id', os.userInfo().gid);
console.log('cwd', process.cwd());
console.log('');
console.log('rss', process.memoryUsage().rss);

console.log('heapTotal', process.memoryUsage().heapTotal);

console.log('heapUsed:', process.memoryUsage().heapUsed);

console.log('external:', process.memoryUsage().external);

console.log('');

console.log('env:', process.env);
console.log('host name:', process.env.HOSTNAME);

console.log('编译 Node.js 可执行文件的配置选项:', process.config);

console.log('生成当前进程的诊断报告:');
console.log(process.report.getReport());

console.log('当前操作系统的 CPU 信息:');
console.log(os.cpus());

console.log('当前操作系统的运行时长信息:');
console.log('系统运行时间:', os.uptime());

console.log('当前操作系统的版本信息:');
console.log('操作系统版本:', os.version());

console.log('当前操作系统的内核信息:');
console.log('内核信息:', os.constants.uv);

console.log('当前操作系统的网卡信息:');
exec('ifconfig', (error, stdout, stderr) => {
    if (error) {
        console.error(`exec error: ${error}`);
        return;
    }
    console.log('ifconfig output:', stdout);
});

console.log('当前操作系统的用户信息:');
console.log('用户信息:', os.userInfo());

